var express = require("express");
var router = express.Router();

var bodyParser = require("body-parser");
var urlencodedParser = bodyParser.urlencoded({ extended: false });

//引入数据模型
var user = require("../model/user");
var comment = require("../model/comment");

router.post("/add-discuss", urlencodedParser, function(req, res) {
    var commentId = req.body.commentId;
    var content = req.body.content;
    var userId = req.session.passport.user;
    comment.findById(commentId, function(err, doc) {
        doc.comments.push({ commentUser: userId, commentContent: content });
        doc.save();
        res.send({ code: 0, status: 0, message: "添加成功" });
    });
});
module.exports = router;